/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import entidad.Person;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.swing.JOptionPane;

/**
 *
 * @author Juan
 */
public class PersonDAO {

    public boolean crear(Person person) {
        boolean respuesta=false;
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPAPracticePU");
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            em.persist(person);
            em.getTransaction().commit();
            respuesta=true;
        } catch (Exception e) {
            em.getTransaction().rollback();
            JOptionPane.showMessageDialog(null, e);
        } finally {
            em.close();
            return respuesta;
        }
    }
}
    